package io.gitee.zhangbinhub.acp.boot.socket.base

import io.netty.handler.codec.ByteToMessageDecoder
import java.util.concurrent.ConcurrentHashMap

/**
 * 初始化任务基类
 *
 * @since JDK 17
 */
abstract class BaseInitSocketServer {
    private val socketServerHandleMap = ConcurrentHashMap<String, SocketServerHandle>()

    private val byteToMessageDecoderMap = ConcurrentHashMap<String, ByteToMessageDecoder>()

    protected fun addServerHandle(name: String, socketServerHandle: SocketServerHandle) {
        socketServerHandleMap[name] = socketServerHandle
    }

    protected fun addMessageDecoder(name: String, byteToMessageDecoder: ByteToMessageDecoder) {
        byteToMessageDecoderMap[name] = byteToMessageDecoder
    }

    protected fun getSocketServerHandle(name: String?): SocketServerHandle? {
        return socketServerHandleMap[name]
    }

    protected fun getMessageDecoder(name: String?): ByteToMessageDecoder? {
        return byteToMessageDecoderMap[name]
    }
}
